<!DOCTYPE html>
<html>
<head>
    <title>财务月收支统计表</title>
    <#include "/header.html">
</head>
<body>
    <div class="grid-btn">
        <div class="col-sm-2">
            <select id="type" name="type" class="form-control">
                <option value="">==请选择收支类型==</option>
                <option value="0">支出</option>
                <option value="1">收入</option>
            </select>
        </div>
        <div class="col-sm-2">
            <input type="text" id="searchDate" class="form-control" placeholder="请选择查询年月" onfocus="WdatePicker({dateFmt:'yyyy-MM'})">
        </div>
        <a class="btn btn-success" id="search">查询</a>
    </div>
    <table id="jqGrid"></table>
    <div id="jqGridPager"></div>
    <script>
        $(function (e) {
            $("#jqGrid").jqGrid({
                url: baseURL + 'cashier/list',
                datatype: "json",
                colModel: [         
                    { label: 'dataId',hidden:true, name: 'dataId', index: 'data_id', width: 50, key: true },
                    { label: '所属经营主体', name: 'subjectName', width: 120 },
                    { label: '事项名称', name: 'name', width: 80 },             
                    { label: '收支类型', name: 'type', width: 60, formatter: function(value, options, row){
                        return value === 0 ? 
                            '<span class="label label-info">支出</span>' : 
                            '<span class="label label-primary">收入</span>';
                    }},         
                    { label: '往来单位', name: 'units', width: 80 },            
                    { label: '金额', name: 'amount', width: 80 },             
                    { label: '记录日期', name: 'operatordate', index: 'operatordate', width: 80 },          
                    { label: '备注', name: 'description', width: 80 }          
                ],
                viewrecords: true,
                height: (pageInfo().height-130),
                rowNum: 15,
                rowList : [15,50,99],
                loadtext : '<img src="../../statics/plugins/layer/skin/default/loading-1.gif" style="margin-right:10px;"/>正在加载,请稍候……',
                rownumbers: true, 
                rownumWidth: 25, 
                autowidth:true,
                multiselect: true,
                pager: "#jqGridPager",
                loadComplete : function(data){
                    if(data.code == 0){
                        return data;
                    }else if(data.code == 205){
                        invalidAccess();
                    }else{
                        layer.alert(data.msg);
                    }
                },
                jsonReader : {
                    root: "page.list",
                    page: "page.currPage",
                    total: "page.totalPage",
                    records: "page.totalCount"
                },
                prmNames : {
                    page:"page", 
                    rows:"limit", 
                    order: "order"
                },
                gridComplete:function(){
                    //隐藏grid底部滚动条
                    $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
                }
            });
            $("#search").click(function(){
                if($('#searchDate').val()!=""){
                    var page = $("#jqGrid").jqGrid('getGridParam','page');
                    $("#jqGrid").jqGrid('setGridParam',{ 
                        postData:{'date': $('#searchDate').val(),'type':$('#type').val()},
                        page:page
                    }).trigger("reloadGrid");
                }else{
                    var page = $("#jqGrid").jqGrid('getGridParam','page');
                    $("#jqGrid").jqGrid('setGridParam',{ 
                        postData:{'type':$('#type').val()},
                        page:page
                    }).trigger("reloadGrid");
                }
            });
        });
    </script>
</body>